package com.study.example.gameserver.module.currency.domain;

public enum CurrencyType {
    GOLD("金币", 1),
    DIAMOND("钻石", 2);

    private final String name;   // 显示名
    private final int type;      // 类型值

    CurrencyType(String name, int type) {
        this.name = name;
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public int getType() {
        return type;
    }

    // 根据类型值获取枚举
    public static CurrencyType of(int type) {
        for (CurrencyType currency : values()) {
            if (currency.getType() == type) {
                return currency;
            }
        }
        throw new IllegalArgumentException("未知类型值: " + type);
    }
}

